package mhwi.powers;

import com.megacrit.cardcrawl.actions.common.ApplyPowerAction;
import com.megacrit.cardcrawl.actions.common.ReducePowerAction;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.powers.StrengthPower;
import mhwi.helper.ModHelper;

public class BaiRenPower extends TemplatePower {
    private static final Class<? extends TemplatePower> CLASS = BaiRenPower.class;
    private static final String CLASS_NAME = CLASS.getSimpleName();
    public static final String POWER_ID = ModHelper.makeId(CLASS_NAME);

    public BaiRenPower(AbstractCreature owner, int amount) {
        super(owner, amount, CLASS);
    }

    public BaiRenPower(AbstractCreature owner) {
        super(owner, 2, CLASS);
    }

    @Override
    public void updateDescription() {
        this.description = super.DESCRIPTIONS[0];
    }

    @Override
    public void stackPower(int stackAmount) {
        if (this.amount == 0) {
            stackAmount = 2;
        } else {
            stackAmount = 2 - this.amount;
        }

        super.stackPower(stackAmount);
    }

    // 加力量
    @Override
    public void onInitialApplication() {
        AbstractDungeon.actionManager.addToTop(
                new ApplyPowerAction(this.owner, this.owner, new StrengthPower(this.owner, 1), 1));
    }

    // 移除力量
    @Override
    public void onRemove() {
        AbstractDungeon.actionManager.addToTop(
                new ReducePowerAction(this.owner, this.owner, StrengthPower.POWER_ID, 1));
    }
}